package com.snail.billing;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class BillingCallback {

	/** 登录回调 */
	public static final String ACTION_LAUNCH = "action.launch";
	/** 登录回调（密码MD5加密） */
	public static final String ACTION_LAUNCH_PWD_MD5 = "action.launch.pwd.md5";
	/** 订单号回调 */
	public static final String ACTION_CREATE_ORDER_NO = "action.create.order.no";
	/** 手机绑定回调 */
	public static final String ACTION_BIND_MOBILE = "action.bind.mobile";
	/** 邮箱绑定回调 */
	public static final String ACTION_BIND_EMAIL = "action.bind.email";
	/** 账号绑定回调 */
	public static final String ACTION_BIND_ACCOUNT = "action.bind.account";
	/** 账号绑定回调（密码MD5加密） */
	public static final String ACTION_BIND_ACCOUNT_PWD_MD5 = "action.bind.account.pwd.md5";
	/** 修改密码回调 */
	public static final String ACTION_MODIFY_PWD = "action.modify.pwd";
	/** 修改密码回调（密码MD5加密） */
	public static final String ACTION_MODIFY_PWD_MD5 = "action.modify.pwd.md5";
	/** 充值回调 */
	public static final String ACTION_IMPREST = "action.imprest";
	/** 支付回调 */
	public static final String ACTION_PAYMENT = "action.payment";

	private Map<String, BillingCallbackResult> map;

	public BillingCallback() {
		map = new HashMap<String, BillingCallbackResult>();
	}

	public void addAction(String action, BillingCallbackResult result) {
		map.put(action, result);
	}

	public Set<String> getActions() {
		return map.keySet();
	}

	public void onCallback(int resultCode, String action, String[] args) {
		if (map.containsKey(action)) {
			BillingCallbackResult result = map.get(action);
			result.onResult(resultCode, action, args);
		}
	}

}
